
package DAO;

import Utils.HibernateUtil;
import java.util.List;
import model.User;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class UserDaoImp implements UserDao{
    
public User getUser(String user,String password){
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    try{
        Query query = session.createSQLQuery("Select * From User where user = :user and password = :password").addEntity(User.class);
        query.setParameter("user",user);
        query.setParameter("password",password);
        List<User> u = query.list();
        return u.get(0);
    }catch(Exception e)
    {
        return null;
    }
}

}
